<template>
    <div class="talk">
        <button @click="talkStore.getATalk">获取一句话</button>
        <ul>
            <li v-for="talk in talkList" :key="talk.id">{{ talk.title }}</li>
        </ul>
    </div>
</template>
<script setup>
import {useTalkStore} from '@/store/talk'
import { storeToRefs } from 'pinia';

const talkStore = useTalkStore()
const {talkList} = storeToRefs(talkStore)

talkStore.$subscribe((mutate,state)=>{
  console.log('LoveTalk',mutate,state)
  localStorage.setItem('talkList',JSON.stringify(talkList.value))
})
</script>
<style scoped>
    .talk{
        background-color: orange;
        margin: 20px 0;
        padding: 10px;
        border-radius: 10px;
        box-shadow: 0 0 10px;
        height: auto;
    }
</style>